using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;  //  for Vector2
using Microsoft.Xna.Framework.Graphics;   //   for Texture2D

namespace zombieArena
{
    class SuperShotgun : Weapon
    {
        private int shotgunPellets = 100;
        Random r = new Random();
        Vector2 recoil;
        float range;
        Matrix rotation;
        float angle;
        Vector2 midPoint = new Vector2(8f, 8f);

        public SuperShotgun(Texture2D t)
            : base(t)
        {
            ammo = 9001;
            rateOfFire = 200f;
            bulletSpeed = 30f;
            name = "Super Shotgun";
            soundIndex = 2;
        }

        public override void shoot(Vector2 position, Vector2 direction, Map map)
        {
            // at least half the bullets on the left side
            for (int i = 0; i < shotgunPellets; i++)
            {
                angle = ((float)r.Next(-400000, 400000) / 10000);
                range = ((float)r.Next(10000, 20000) / 10000);
                recoil = new Vector2(direction.X * range, direction.Y * range);

                rotation = Matrix.CreateRotationZ(MathHelper.ToRadians(angle));

                map.bulletList.Add(new Bullet(position, Vector2.Transform(recoil, rotation) * bulletSpeed, texture, 1, 40f, 0f, 10000f, 0f, midPoint));
            }
        }
    }
}
